﻿using UnityEngine;
using System.Collections;

public class EnemyScript : MonoBehaviour {

	public float minSpeed;
	public float maxSpeed;
	public float currentSpeed;
	private float x, y, z;

	// Use this for initialization
	void Start () {
		SetPositionAndSpeed ();
	}
	
	// Update is called once per frame
	void Update () {
		float amtToMove = currentSpeed * Time.deltaTime;
		transform.Translate (Vector3.down * amtToMove);

		if (transform.position.y <= -2) {
			SetPositionAndSpeed ();
		}

	}

	public void SetPositionAndSpeed(){
		currentSpeed = Random.Range (minSpeed, maxSpeed);

		x = Random.Range (-6f, 6f);
		y = 10.0f;
		z = 0.0f;
		transform.position = new Vector3 (x, y, z);
	}
}